<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后花园：CPCC</title>
</head>
<link rel="stylesheet" href="/static/css/layui.css">
<style>
    .layui-row{
        margin-top: 40%;
    }
     h2{
        text-align: center;
        margin-bottom: 1rem;
    }
     body{
         background-color: silver;
     }
</style>
<body>
<div class="layui-container">
    <div class="layui-row">
        <div class="layui-col-xs4 layui-col-sm6 layui-col-md4">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </div>
        <div class="layui-col-xs4 layui-col-sm6 layui-col-md4">
            <div class="grid-demo grid-demo-bg1">
                <div>
                    <h2>用&nbsp;&nbsp;户&nbsp;&nbsp;登&nbsp;&nbsp;录</h2>
                    <form class="layui-form" action="">

                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width: auto">账号</label>
                            <div class="layui-input-block" style="margin-left: 60px;">
                                <input type="text" id="user" name="user" lay-verify="required" lay-reqtext="账号是必填项，岂能为空？" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width: auto">密码</label>
                            <div class="layui-input-block" style="margin-left: 60px;">
                                <input type="password" id="password" name="password" lay-verify="required" lay-reqtext="密码是必填项，岂能为空？" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block" style="margin-left: 60px;">
                                <button type="button" class="layui-btn ok" lay-submit="" lay-filter="demo1">立即登录</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4 layui-col-sm12 layui-col-md4">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </div>
    </div>
</div>
</body>
<script src="/static/layui.js"></script>
<script src="/static/vendor/jquery/jquery-1.12.4.min.js"></script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;
        $('.ok').click(function () {
            var user = $("#user").val();
            var password = $("#password").val();
            $.post('{:url("admin/login/index")}', {
                    'user': user,
                    'password': password
                }
                , function (res) {
                    if (res.code == 1) {
                        location.href=res.url;
                    } else {
                        layer.msg(res.msg,{icon: 2});
                    }
                }, 'json');
        })

    });
</script>
</html>